<?php

namespace App\Modules\Admin\Repositories\Transformers;

use App\Models\Activity;
use App\Models\ActivityForm;
use League\Fractal\TransformerAbstract;

class ActivityFormTransformer extends TransformerAbstract
{
    public function transform(ActivityForm $activityForm)
    {
        $activity = $activityForm->activity;

        // 身份证隐藏
        // $idCard = strlen($activityForm->id_card) == 15 ? substr_replace($activityForm->id_card, "******", 6, 6) : (strlen($activityForm->id_card) == 18 ? substr_replace($activityForm->id_card, "********", 6, 8) : "身份证位数不正常！");

        return [
            'id' => $activityForm->id,
            'activity_name' => $activity->title,
            'name' => $activityForm->name,
            'sex' => $activityForm->sex,
            'phone' => $activityForm->phone,
            'id_card' => $activityForm->id_card,
            // 'id_card' => $idCard,
            'audit_status' => $activityForm->audit_status,
            'created_at' => $activityForm->created_at != null ? $activityForm->created_at->toDateTimeString() : null,
        ];

    }
}
